<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
 	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <%-- <div class="ibox-title" style="border-color: white;">
                    <div class="row">
                        <div class="col-sm-3" style="width: 100%;">
                            <div class="input-group" style="width: 100%;">
                                <input id="name" type="text" placeholder="请输入名称" class="input-sm form-control" style="width: 15%;">
                                <span class="input-group-btn"  style="float: left;">
                                        <a id="find_btn" type="button" class="btn btn-sm btn-primary"> 搜索</a> </span>
	                            <s:hasPermission name="demandInterview:add">
	                            	 <span class="input-group-btn" style="float: left; margin-left: 25px;">
	                             		<a  class="btn btn-sm btn-success" style="margin-left: 20px;" onclick="showadd();"> 添加</a>
	                             	 </span>
	                            </s:hasPermission>
                             </div>
                        </div>
                    </div>
                </div> --%>
                <!-- biaogebigin -->
                <div class="ibox-content" style=" padding-left: 0px; margin-top: 10px;">
                    <div class="jqGrid_wrapper">
                        <table id="table_list"></table>
                        <div id="pager_list"></div>
                    </div>
                </div>
                <!-- tableover -->
            </div>
            <!-- PAGE CONTENT ENDS HERE -->

        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<script type="text/javascript">
        var communicateid = '${communicateId}';
        $.jgrid.defaults.styleUI = "Bootstrap";
        $("#table_list").jqGrid({
            url: '<%=contextPath%>/demandInterview/listData',
            datatype: "json",
            postData: {'communicateId':communicateid}, //发送数据
            autowidth: true,
            rownumbers: true,
            shrinkToFit: true,
            mtype: "post",
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: [
			"id",
			"面试时间",
			"面试地点",
			"面试对接人",
			"对接人电话",
			"面试反馈",
			"面试状态",
			"操作"],
            colModel: [
			{name: "id",index: "id",hidden: true}, 
			{name:"interDate",index:"interDate",width:100},
			{name:"address",index:"address",width:100},
			{name:"docker",index:"docker",width:100},
			{name:"phone",index:"phone",width:100},
			{name:"reason",index:"reason",width:100},
			{name:"status",index:"status",width:80,
				formatter: function (value, options, row) {
					var htm="";
					if(value == 0){
						htm = "<span class='label label-default'>未反馈</span>";
					}else if(value == 1){
						htm = "<span class='label label-success'>通过</span>";
					}else if(value == 2){
						htm = "<span class='label label-danger'>未通过</span>";
					}
					return htm;
				}
			},
			{
			 formatter: function (cellvalue, options, row) {
             	var htm="";
             		if(row.status != 2){
             			htm+="  <a class='btn btn-sm btn-primary' title='面试反馈' onclick='addfeedback(&quot;" + row.id + "&quot;,&quot;" + row.communicateId + "&quot;)'><i class='icon-ok'></i></a>";
             		}
             		htm+="  <a class='btn btn-sm btn-info' title='查看' onclick='showeye(&quot;" + row.id + "&quot;)'><i class='icon-eye-open'></i></a>";
             		
             		return htm;
			 }
			}
			],
            height: $(window).height() - 170,
            pager: "#pager_list",
            multiselect: true,//多选按钮
            //multiboxonly: true,
            viewrecords: true,
            hidegrid: false
        });
        //表格自适应高宽
        $(window).bind("resize", function () {
            var b = $(".jqGrid_wrapper").width();
            $("#table_list").setGridWidth(b);
            $("#table_list").setGridHeight($(window).height() - 170);
        })
        $("#table_list").navGrid('#pager_list', {edit: false, add: false, del: false, search: false})
        /* 判断是否有添加权限 */
        //检索
        $("#find_btn").click(function () {
            var name = $("#name").val();
            $("#table_list").jqGrid('setGridParam', {
                postData: {'name': name}, //发送数据
                page: 1
            }).trigger("reloadGrid"); //重新载入
        });
        
    //查看
    function showeye(id) {
        openyem("查看沟通记录", "<%=contextPath%>/demandInterview/detailView?id=" + id, 550, 500);
    }
    //删除
    function del(id) {
        swalopen(id, "<%=contextPath%>/demandInterview/delete");
    };
    //修改
    function showedit(id) {
        openyem("修改沟通记录", "<%=contextPath%>/demandInterview/editView?id=" + id, 550, 500);
    }
    //添加
    function showadd(id) {
        openyem("添加沟通记录", "<%=contextPath%>/demandInterview/addView", 550, 500);
    }
    function addfeedback(id,communicateId) {
		swal({ 
			title: "是否参加面试？", 
			type: "warning", 
			showCancelButton: true, 
			confirmButtonColor: "#DD6B55", 
			confirmButtonText: "No", 
			cancelButtonText: "Yes", 
			closeOnConfirm: false, 
			closeOnCancel: false 
			}, 
			function(isConfirm) { 
				if (isConfirm) { 
					swal({
	       		    	title:"请填写",
	       		    	type: "input",
	       		    	showCancelButton: true, 
	       			    closeOnConfirm: false, 
	       			    cancelButtonText: "取消", 
	       			    confirmButtonText: "确认",
	       		    	inputPlaceholder: "请填写未参加原因",
	       		    	showLoaderOnConfirm: true
	       		    },function(inputValue){ 
	       				if(inputValue === false){
	       					return false
	       				}else {
	       					if (inputValue === "") { 
	       						swal.showInputError("请填写未参加原因");
	       					    return false 
	       					}else{
	       						$.ajax({
	       							url: '<%=contextPath%>/demandInterview/updateStatus',
	       							data:{
	       								'id':id,
	       								'status':2,
	       								'reason':inputValue
	       								},
	       			                type: 'post',
	       			                dataType: "json",
	       			                beforeSend: function () {
	       						        // 禁用按钮防止重复提交
	       								swal("信息已经提交，请等待后台处理~！");
	       						    },
	       							success : function(data) {
	       								if (data.code == 200) {
	       									swal({
	       										title : data.message,
	       										type : "success",
	       										showCancelButton : false,
	       										confirmButtonText : "确定",
	       										animation : "slide-from-bottom",
	       										text: "2秒后自动关闭。", 
	       				      	    			timer: 2000, 
	       										closeOnConfirm : true
	       									}, function() {
	       										window.location.reload();//刷新当前页面
	       									});
	       								} else {
	       									swal("错误", data.message, "error");
	       								}  
	       							}
	       						});
	       					}
						}
	       			});
					} else{ 
						swal({
       		    			title:"即将进入面试反馈",
       		    			text: "1秒后自动关闭。", 
       		    			timer: 1000, 
       					    showConfirmButton: false
       		    		});
						openyem("反馈面试结果", "<%=contextPath%>/demandInterview/editView?id=" + id, 550, 500);
					}
			})
	}
</script>
</body>
</html>

